﻿Public Class DtpoInmueble

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String) As List(Of EtpoInmueble)
        Dim tpoInmuebles As List(Of EtpoInmueble) = Nothing

        Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings(descEmpresa).ConnectionString)
            Using cmd As New SqlCommand("usp_TtpoInmueble_sel", cn)
                cmd.CommandType = CommandType.StoredProcedure
                Try
                    cn.Open()
                    Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.CloseConnection)
                        If dr.HasRows Then
                            tpoInmuebles = New List(Of EtpoInmueble)
                            Dim inmueble As EtpoInmueble = Nothing
                            Do While dr.Read
                                inmueble = New EtpoInmueble( _
                                    dr.GetInt32(dr.GetOrdinal("idTpoInmueble")), _
                                    dr.GetString(dr.GetOrdinal("descTpoInmueble")))
                                tpoInmuebles.Add(inmueble)
                            Loop
                            dr.Close()
                        End If
                    End Using
                Catch ex As Exception
                    Throw
                End Try
            End Using
        End Using

        Return tpoInmuebles
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal idTipoDoc As Int32) As Boolean
        Dim resultado As Boolean = False

        Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings(descEmpresa).ConnectionString)
            Using cmd As New SqlCommand("usp_tpoDocmto_del", cn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.Add("@idTipoDoc ", SqlDbType.Int).Value = idTipoDoc
                Try
                    cn.Open()
                    cmd.ExecuteNonQuery()
                    resultado = True
                Catch ex As Exception
                    Throw
                End Try
            End Using
        End Using

        Return resultado
    End Function

End Class
